<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.ht.finance.dao.${ClassName}Dao">

    <resultMap type="com.ht.finance.vo.${ClassName}VO" id="${className}Map">
        <#list fieldList as field>
        <result property="${field.attrName}" column="${field.fieldName}"/>
        </#list>
    </resultMap>

    <select id="selectPageWithSql" resultType="com.ht.finance.vo.${ClassName}VO"
            parameterType="com.ht.finance.query.${ClassName}Query">
        SELECT  a.* FROM ${tableName} a  where  1=1
        <#list fieldList as field>
            <#if field.attrType == 'String'>
                <if test="query.${field.attrName}!=null and query.${field.attrName}!=''">
                    and a.${field.fieldName} like CONCAT('%', #\{query.${field.attrName}}, '%')
                </if>
            </#if>


 <#if field.attrType != 'String'>
                <if test="query.${field.attrName}!=null and query.${field.attrName}!=''">
                    and a.${field.fieldName} = #\{query.${field.attrName}}
                </if>
 </#if>
        </#list>
        order by a.id desc
    </select>

    <select id="selectListWithSql" resultType="com.ht.finance.vo.${ClassName}VO"
            parameterType="com.ht.finance.query.${ClassName}Query">
        SELECT  a.* FROM ${tableName} a  where  1=1
        <#list fieldList as field>
            <#if field.attrType == 'String'>
                <if test="query.${field.attrName}!=null and query.${field.attrName}!=''">
                    and a.${field.fieldName} like CONCAT('%', #\{query.${field.attrName}}, '%')
                </if>
            </#if>


            <#if field.attrType != 'String'>
                <if test="query.${field.attrName}!=null and query.${field.attrName}!=''">
                    and a.${field.fieldName} = #\{query.${field.attrName}}
                </if>
            </#if>
        </#list>
        order by a.id desc
    </select>
</mapper>